package krow.dev.gunpobus.util;

import android.content.Context;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.AnimationUtils;
import android.view.animation.RotateAnimation;

public class AnimationUtil {

	public static Animation createRotateAnimation(Context context, int fromDegree, int toDegree) {

		AnimationSet animationSet = new AnimationSet(true);

		RotateAnimation rotateAnimation = new RotateAnimation(
				fromDegree, 
				toDegree, 
				Animation.RELATIVE_TO_SELF, 0.5F, 
				Animation.RELATIVE_TO_SELF, 0.5F);
		rotateAnimation.setInterpolator(AnimationUtils.loadInterpolator(context, android.R.anim.linear_interpolator));
		rotateAnimation.setDuration(3000);
		rotateAnimation.setRepeatCount(Animation.INFINITE);
		animationSet.addAnimation(rotateAnimation);

		AlphaAnimation alphaAnimation = new AlphaAnimation(0.5F, 0.5F);
		alphaAnimation.setDuration(3000);
		animationSet.addAnimation(alphaAnimation);

		return animationSet;
	}
}
